﻿<?xml version="1.0" encoding="utf-8" ?>

<xsd:schema elementFormDefault="qualified" attributeFormDefault="unqualified"
     blockDefault="#all"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
     targetNamespace="http://schemas.microsoft.com/windows/annotations/2003/11/base"
     xmlns:anb="http://schemas.microsoft.com/windows/annotations/2003/11/base"
     xmlns:anc="http://schemas.microsoft.com/windows/annotations/2003/11/core">

	<xsd:import schemaLocation="AnnotationCoreV1.xsd"
		 namespace="http://schemas.microsoft.com/windows/annotations/2003/11/core"/>

	<!-- ***** Author ***** -->
	<!-- Simple DisplayName Author -->
	<xsd:complexType name="StringAuthorType">
		<xsd:simpleContent >
			<xsd:extension base='xsd:string' />
		</xsd:simpleContent>
	</xsd:complexType>
	<xsd:element name="StringAuthor" type="anb:StringAuthorType"
				 substitutionGroup="anc:Author"/>

	<!-- ***** LocatorParts ***** -->

	<!-- Helper types -->

	<!-- CountItemNameType - helper type to define count item -->
	<xsd:simpleType name="CountItemNameType">
		<xsd:restriction base='xsd:string'>
			<xsd:pattern value="Count" />
		</xsd:restriction>
	</xsd:simpleType>

	<!-- NumberType - helper type to define segment count item -->
	<xsd:simpleType name="NumberType">
		<xsd:restriction base='xsd:string'>
			<xsd:pattern value="\d*" />
		</xsd:restriction>
	</xsd:simpleType>

	<!-- SegmentNameType: helper type to define possible segment name types -->
	<xsd:simpleType name="SegmentItemNameType">
		<xsd:restriction base='xsd:string'>
			<xsd:pattern value="Segment\d*" />
		</xsd:restriction>
	</xsd:simpleType>


	<!-- Flow Locator Part -->

	<!-- FlowSegmentValueItemType: helper type to define flow segment values -->
	<xsd:simpleType name="FlowSegmentItemValueType">
		<xsd:restriction base='xsd:string'>
			<xsd:pattern value=" \d*,\d*" />
		</xsd:restriction>
	</xsd:simpleType>

	<!-- FlowItemType -->
	<xsd:complexType name="FlowItemType" abstract = "true">
		<xsd:complexContent>
			<xsd:restriction base="anc:ItemType">
			</xsd:restriction>
		</xsd:complexContent>
	</xsd:complexType>

	<!-- FlowSegmentItemType -->
	<xsd:complexType name="FlowSegmentItemType">
		<xsd:complexContent>
			<xsd:restriction base="anb:FlowItemType">
				<xsd:attribute name="Name" use="required"
							   type="anb:SegmentItemNameType"/>
				<xsd:attribute name="Value" use="required"
							   type="anb:FlowSegmentItemValueType"/>
			</xsd:restriction>
		</xsd:complexContent>
	</xsd:complexType>

	<!-- FlowCountItemType -->
	<xsd:complexType name="FlowCountItemType">
		<xsd:complexContent>
			<xsd:restriction base="anb:FlowItemType">
				<xsd:attribute name="Name" type="anb:CountItemNameType" use="required"/>
				<xsd:attribute name="Value" type="anb:NumberType" use="required"/>
			</xsd:restriction>
		</xsd:complexContent>
	</xsd:complexType>

	<!-- CharacterRangeType is an extension of ContentLocatorPartType that locates
  *    part of the content within a FlowDocument. CharacterRangeType contains one
  *    "Item" element with name "Count" and value the number(N) of "SegmentXX"
  *    elements that this ContentLocatorPart has.  It also contains N "Item"
  *    elements with name "SegmentXX" where XX is a number from 0 to N-1. The
  *    value of each "SegmnetXX" element is a string in the form "offset, length"
  *    which locates one sequence of symbols in the FlowDocument. Example:

  *        <anb:CharacterRange>
  *          <anc:Item Name="Count" Value="2" />
  *          <anc:Item Name="Segment0" Value="5,10" />
  *          <anc:Item Name="Segment1" Value="25,2" />
  *        </anb:ChacterRange>
  -->
	<xsd:complexType name="CharacterRangeType">
		<xsd:complexContent>
			<xsd:extension base="anc:ContentLocatorPartType">
				<xsd:sequence minOccurs="1" maxOccurs="unbounded">
					<xsd:element name="Item" type="anb:FlowItemType" />
				</xsd:sequence>
			</xsd:extension>
		</xsd:complexContent>
	</xsd:complexType>

	<!-- CharacterRange element substitutes ContentLocatorPart element -->
	<xsd:element name="CharacterRange" type="anb:CharacterRangeType"
				 substitutionGroup="anc:ContentLocatorPart"/>

	<!-- Fixed LocatorPart -->

	<!-- Helper type – FixedItemType -->
	<xsd:complexType name="FixedItemType" abstract = "true">
		<xsd:complexContent>
			<xsd:restriction base="anc:ItemType">
			</xsd:restriction>
		</xsd:complexContent>
	</xsd:complexType>

	<!-- Helper type – FixedCountItemType: ContentLocatorPart items count -->
	<xsd:complexType name="FixedCountItemType">
		<xsd:complexContent>
			<xsd:restriction base="anb:FixedItemType">
				<xsd:attribute name="Name" type="anb:CountItemNameType" use="required"/>
				<xsd:attribute name="Value" type="anb:NumberType" use="required"/>
			</xsd:restriction>
		</xsd:complexContent>
	</xsd:complexType>

	<!-- Helper type -FixedSegmentValue: Defines possible fixed segment values -->
	<xsd:simpleType name="FixedSegmentItemValueType">
		<xsd:restriction base='xsd:string'>
			<xsd:pattern value="\d*,\d*,\d*,\d*" />
		</xsd:restriction>
	</xsd:simpleType>

	<!-- Helper type - FixedSegmentItemType -->
	<xsd:complexType name="FixedSegmentItemType">
		<xsd:complexContent>
			<xsd:restriction base="anb:FixedItemType">
				<xsd:attribute name="Name" use="required"
							   type="anb:SegmentItemNameType"/>
				<xsd:attribute name="Value" use="required"
							   type="anb:FixedSegmentItemValueType "/>
			</xsd:restriction>
		</xsd:complexContent>
	</xsd:complexType>

	<!-- FixedTextRangeType is an extension of ContentLocatorPartType that locates
  *    content within a FixedDocument.  It contains one "Item" element with name
  *    "Count" and value the number (N) of "Item" elements with name "SegmentXX"
  *    that this ContentLocatorPart has.  FixedTextRange locator part also
  *    contains N "Item" elements with one attribute Name="SegmentXX" where XX is
  *    a number from 0 to N-1 and one attribute "Value" in the form "X1, Y1, X2,
  *    Y2".  Here X1,Y1 are the coordinates of the start symbol in this segment,
  *    X2,Y2 are the coordinates of the end symbol in this segment.  Example:
  *
  *        <anb:FixedTextRange>
  *          <anc:Item Name="Count" Value="2" />
  *          <anc:Item Name="Segment0" Value="10,5,20,5" />
  *          <anc:Item Name="Segment1" Value="25,15, 25,20" />
  *        </anb:FixedTextRange>
  -->
	<xsd:complexType name="FixedTextRangeType">
		<xsd:complexContent>
			<xsd:extension base="anc:ContentLocatorPartType">
				<xsd:sequence minOccurs="1" maxOccurs="unbounded">
					<xsd:element name="Item" type="anb:FixedItemType" />
				</xsd:sequence>
			</xsd:extension>
		</xsd:complexContent>
	</xsd:complexType>

	<!-- FixedTextRange element substitutes ContentLocatorPart element -->
	<xsd:element name="FixedTextRange" type="anb:FixedTextRangeType"
				 substitutionGroup="anc:ContentLocatorPart"/>

	<!-- DataId -->

	<!-- ValueItemNameType: helper type to define value item -->
	<xsd:simpleType name="ValueItemNameType">
		<xsd:restriction base='xsd:string'>
			<xsd:pattern value="Value" />
		</xsd:restriction>
	</xsd:simpleType>

	<!-- StringValueItemType -->
	<xsd:complexType name="StringValueItemType">
		<xsd:complexContent>
			<xsd:restriction base="anc:ItemType">
				<xsd:attribute name="Name" type="anb:ValueItemNameType" use="required"/>
				<xsd:attribute name="Value" type="xsd:string" use="required"/>
			</xsd:restriction>
		</xsd:complexContent>
	</xsd:complexType>

	<xsd:complexType name="StringValueLocatorPartType">
		<xsd:complexContent>
			<xsd:extension base="anc:ContentLocatorPartType">
				<xsd:sequence minOccurs="1" maxOccurs="1">
					<xsd:element name="Item" type="anb:ValueItemType" />
				</xsd:sequence>
			</xsd:extension>
		</xsd:complexContent>
	</xsd:complexType>

	<!-- DataId element substitutes ContentLocatorPart and is used to locate a
  *    subtree in the logical tree.  Including DataId locator part in a
  *    ContentLocator helps to narrow down the search for a particular content.
  *    Examle of DataId ContentLocatorPart:
  *    
  *        <anb:DataId>
  *          <anc:Item Name="Value" Value="FlowDocument" />
  *        </anb:DataId>
  -->

	<xsd:element name="DataId" type="anb: StringValueLocatorPartType "
				 substitutionGroup="anc:ContentLocatorPart"/>

	<!-- PageNumber -->

	<!-- NumberValueItemType -->
	<xsd:complexType name="NumberValueItemType">
		<xsd:complexContent>
			<xsd:restriction base="anc:ItemType">
				<xsd:attribute name="Name" type="anb:ValueItemNameType" use="required"/>
				<xsd:attribute name="Value" type="anb:NumberType" use="required"/>
			</xsd:restriction>
		</xsd:complexContent>
	</xsd:complexType>

	<xsd:complexType name="NumberValueLocatorPartType">
		<xsd:complexContent>
			<xsd:extension base="anc:ContentLocatorPartType">
				<xsd:sequence minOccurs="1" maxOccurs="1">
					<xsd:element name="Item" type="anb:ValueItemType" />
				</xsd:sequence>
			</xsd:extension>
		</xsd:complexContent>
	</xsd:complexType>

	<-- PageNumber element substitutes ContentLocatorPart and is used to locate a
	*  page in a FixedDocument.  PageNumber ContentLocatorPart is used in
	*   conjunction with the FixedTextRange ContentLocatorPart and it shows on with
	*   page are the coordinates defined in the FixedTextRange.
	*   Example of a PageNumber ContentLocatorPart:
	*
	*       <anb:PageNumber>
		*         <anc:Item Name="Value" Value="1" />
		*
	</anb:PageNumber>
	-->
	<xsd:element name="PageNumber" type="anb:NumbnerValueLocatorPartType"
				 substitutionGroup="anc:ContentLocatorPart"/>

	<!-- ***** Content ***** -->
	<!-- Highlight colors – defines highlight color for annotations of type
  *    Highlight or normal and active anchor colors for annotations of type
  *    TextStickyNote and InkStickyNote. 
  -->
	<xsd:complexType name="ColorsContentType">
		<xsd:attribute name="Background" type='xsd:string' use="required" />
		<xsd:attribute name="ActiveBackground" type='xsd:string' use="optional" />
	</xsd:complexType>

	<xsd:element name="Colors" type="anb:ColorsContentType"
				 substitutionGroup="anc:Content"/>

	<!-- RTB Text –contains XAML representing StickyNote Reach Text Box text.
  *    Used in annotations of type TextStickyNote. -->
	<xsd:complexType name="TextContentType">
		<!-- See XAML schema for RTB content -->
	</xsd:complexType>

	<xsd:element name="Text" type="anb:TextContentType"
				 substitutionGroup="anc:Content"/>

	<-- Ink – contains XAML representing Sticky Note ink.
	*   Used in annotations of type InkStickyNote. -->
	<xsd:complexType name="InkContentType">
		<!-- See XAML schema for Ink content -->
	</xsd:complexType>

	<xsd:element name="Ink" type="anb:InkContentType"
				 substitutionGroup="anc:Content"/>

	<!-- SN Metadata – defines StickyNote attributes as position width, height,
  *    etc.  Used in annotations of type TextStickyNote and InkStickyNote. -->
	<xsd:complexType name="MetadataContentType">
		<xsd:attribute name="Left" type='xsd:decimal' use="optional"  />
		<xsd:attribute name="Top" type='xsd:decimal' use="optional" />
		<xsd:attribute name="Width" type='xsd:decimal' use="optional" />
		<xsd:attribute name="Height" type='xsd:decimal' use="optional" />
		<xsd:attribute name="XOffset" type='xsd:decimal' use="optional" />
		<xsd:attribute name="YOffset" type='xsd:decimal' use="optional" />
		<xsd:attribute name="ZOrder" type='xsd:decimal' use="optional" />
	</xsd:complexType>

	<xsd:element name="Metadata" type="anb:MetadataContentType"
				 substitutionGroup="anc:Content"/>

</xsd:schema>
